package com.opo5.logisticsmanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.opo5.logisticsmanagement.Vo.MaterialVo;
import com.opo5.logisticsmanagement.Vo.NewVo;
import com.opo5.logisticsmanagement.dao.NewDao;
import com.opo5.logisticsmanagement.domain.New;
import com.opo5.logisticsmanagement.domain.SparePlan;
import com.opo5.logisticsmanagement.service.NewService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NewServiceImpl extends ServiceImpl<NewDao,New> implements NewService {
    @Autowired
    private NewDao newDao;
    @Override
    public IPage<New> selectPage(int currentPage, int pageSize, New n) {
        LambdaQueryWrapper<New> lqw=new LambdaQueryWrapper<>();
        lqw.eq(n.getPlantype()!=null,New::getPlantype,n.getPlantype());
        lqw.eq(n.getProjectnum()!=null,New::getProjectnum,n.getProjectnum());
        lqw.like(Strings.isNotEmpty(n.getProjectname()),New::getProjectname,n.getProjectname());
        lqw.eq(n.getPurchasenum()!=null,New::getPurchasenum,n.getPurchasenum());
        lqw.eq(n.getPlanstate()!=null,New::getPlanstate,n.getPlanstate());
        IPage<New>page=new Page<>(currentPage,pageSize);
        newDao.selectPage(page,lqw);
        return page;
    }

    @Override
    public Page<NewVo> getPageVo(Page<NewVo> iPage) {
        return newDao.newpro(iPage);
    }

}
